package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.SupplierUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * 供应商负责人
 * @author Jian.Wang
 * @date 2019/1/30 16:41
 * @since v1.0
 * @version v1.0
 */
public interface SupplierUserModel extends IModel<SupplierUserEntity> {
    /**
     * 供应商负责人数据插入
     * @param entity 供应商实体
     * @author Jian.Wang
     * @date 2019/1/30 16:47
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer insert(SupplierUserEntity entity) throws XbbException;
    /**
     * 供应商负责人数据更新
     * @param entity 供应商实体
     * @author Jian.Wang
     * @date 2019/1/30 16:47
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer update(SupplierUserEntity entity) throws XbbException;
    /**
     * 供应商负责人数据查询多个
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/30 16:47
     * @since v1.0
     * @return List<SupplierEntityExt>
     */
    @Override
    List<SupplierUserEntity> findEntitys(Map<String, Object> param);
    /**
     * 供应商负责人数据查询条数
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/30 16:47
     * @since v1.0
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);

    /**
     * 供应商负责人数据单条查询
     * @param key 主键ID
     * @param corpid 公司ID
     * @author Jian.Wang
     * @date 2019/1/30 16:47
     * @since v1.0
     * @return Integer
     */
    SupplierUserEntity getByKey(Long key, String corpid);

    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/3/6 22:20
     * @param supplierIdIn 供应商id列表
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteBySupplierIdIn(List<Long> supplierIdIn, String corpid) throws XbbException;

    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    /**
     * 保存协同团队
     *
     * @param supplierUserEntity 实体
     * @throws XbbException 异常
     */
    Integer save(SupplierUserEntity supplierUserEntity) throws XbbException;

    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);

    /**
     * 删除
     *
     * @param supplierUserEntity
     * @author GuoJun.HU
     * @since V1.0
     * @throws XbbException XbbException
     * @date 2019/4/19 15:36
     */
    void delete(SupplierUserEntity supplierUserEntity) throws XbbException;

    /**
     * 通过供应的id获取团队
     *
     * @param corpid        公司id
     * @param supplierId    供应商id
     * @author GuoJun.HU
     * @since V1.0
     * @return List
     * @date 2019/4/19 15:39
     */
    List<SupplierUserEntity> getSupplierUserListBySupplierId(String corpid, Long supplierId);

    /**
     * 获取供应商负责人/协同人的id
     * @param corpid 公司id
     * @param supplierIds 供应商id
     * @param isMain 是否为负责人 1 负责人 0协同人 null所有负责人合协同人
     * @return java.util.List<java.lang.String> 供应商负责人/协同人id
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    List<String> getSupplierUserIdList(String corpid, List<Long> supplierIds, Integer isMain);

    /**
     * 批量新增
     * @param supplierUserEntityList
     * @return
     * @throws XbbException
     */
    void insertBatch(List<SupplierUserEntity> supplierUserEntityList, boolean isImport) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;

    void deleteBatchUser(List<SupplierUserEntity> supplierUserEntityList, String corpid, Integer del) throws XbbException;

    void updateBatch(List<SupplierUserEntity> supplierUserEntities, String corpid) throws XbbException;




    /**
     * 编辑团队成员标签
     *
     * @param supplierUserEntity
     */
    void editLabel(SupplierUserEntity supplierUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param supplierUserEntity
     */
    void updateEditFormPer(SupplierUserEntity supplierUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}
